<!DOCTYPE html>
<html xmlns:th="http://java.sun.com/xml/ns/persistence/orm">

<head>
  <meta charset="UTF-8">
  <title>角色管理-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../static/css/font.css">
  <link rel="stylesheet" href="../../../static/css/weadmin.css">
  <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script>
  <script>
    $(function () {
      $.get({
        url: "/role/list",
        success: function (data) {
          $("#roleList").html(data)
        },
        async: false
      })
    })
  </script>
</head>

<body>
  <div class="weadmin-nav">
    <span class="layui-breadcrumb">
      <a href="">首页</a>
      <a href="">管理员管理</a>
      <a>
        <cite>角色管理</cite></a>
    </span>
    <a class="layui-btn layui-btn-sm" style="margin-top:3px;float:right"
      href="javascript:location.replace(location.href);" title="刷新">
      <i class="layui-icon layui-icon-refresh"></i></a>
  </div>
  <div class="weadmin-body">
    <div class="layui-row">
      <form class="layui-form layui-col-md12 we-search">
        <div class="layui-inline">
          <input class="layui-input" placeholder="开始日" name="start" id="start">
        </div>
        <div class="layui-inline">
          <input class="layui-input" placeholder="截止日" name="end" id="end">
        </div>
        <div class="layui-inline">
          <input type="text" name="username" placeholder="请输入角色名" autocomplete="off" class="layui-input">
        </div>
        <button class="layui-btn" lay-submit="" lay-filter="search"><i
            class="layui-icon layui-icon-search"></i></button>
      </form>
    </div>
    <div class="weadmin-block">
      <button class="layui-btn layui-btn-danger" onclick="delAll()"><i
          class="layui-icon layui-icon-delete"></i>批量删除</button>
      <button class="layui-btn" onclick="WeAdminShow('添加用户','./role-add.html')"><i
          class="layui-icon layui-icon-add-circle-fine"></i>添加</button>
      <span class="fr" style="line-height:40px">共有数据：<span>[[${session.roleNum}]]</span> 条</span>
    </div>
    <table class="layui-table" id="roleList" th:fragment="roleList">
      <thead>
        <tr>
          <th>
            <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i
                class="layui-icon layui-icon-ok"></i>
            </div>
          </th>
          <th>ID</th>
          <th>角色名</th>
          <th>拥有权限规则</th>
          <th>描述</th>
          <th>状态</th>
          <th>操作</th>
      </thead>
      <tbody th:each="role:${session.roles}">
        <tr th:data-id='${role.roleId}'>
          <td>
            <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id=''><i
                class="layui-icon layui-icon-ok"></i></div>
          </td>
          <td>[[${role.roleId}]]</td>
          <td>[[${role.roleName}]]</td>
          <td>[[${role.permission}]]</td>
          <td>[[${role.description}]]</td>
          <td class="td-status">
            <span th:if="${role.roleStatus}==1" class="layui-btn layui-btn-normal layui-btn-xs">已启用</span>
            <span th:if="${role.roleStatus}==0" class="layui-btn layui-btn-normal layui-btn-xs layui-btn-disabled">已停用</span>
          </td>
          <td class="td-manage">
            <a th:if="${role.roleStatus}==1" onclick="member_stop(this,'10001')" href="javascript:;" title="启用">
              <i class="layui-icon layui-icon-download-circle"></i>
            </a>
            <a th:if="${role.roleStatus}==0" onclick="member_stop(this,'10001')" href="javascript:;" title="停用">
              <i class="layui-icon layui-icon-upload-circle"></i>
            </a>
            <a title="编辑" onclick="WeAdminEdit('编辑角色','./role-edit.html',this,1097,500)" href="javascript:;">
              <i class="layui-icon layui-icon-edit"></i>
            </a>
            <a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">
              <i class="layui-icon layui-icon-delete"></i>
            </a>
          </td>
        </tr>
      </tbody>
    </table>
    <div class="page">
      <div class="list" th:fragment="page">
        <span class="num" th:each="page:${session.rolePages}" th:uuid="${page}">[[${page}]]</span>
      </div>
    </div>
  </div>
  <script src="../../../static/lib/layui/layui.js" type="text/javascript"></script>
  <script src="../../../static/js/roleDel.js" type="text/javascript"></script>

  <!--  查找用户-->
  <script>
    layui.use(['form', 'layer', "jquery"], function () {
      var form = layui.form,
              layer = layui.layer,
              $ = layui.jquery;

      //监听提交
      form.on('submit(search)', function (data) {
        var f = data.field;
        var name = f.username;
        if(name!="") {
          $.get({
            url: "/role/find/"+name,
            success: function (data) {
              $("#roleList").html(data)
              $(".num[uuid=1]").addClass("current")
              $(".num[uuid=1]").siblings().removeClass("current")
            },
            async: false
          })
        }
        return false;
      });
    });
  </script>


  <!--  换页-->
  <script>
    $(".num[uuid=1]").addClass("current")
    $(".num").click(function () {
      var page = $(this).attr("uuid")
      $.post({
        url: "/role/page/"+page,
        contentType: "application/json;charset=UTF-8",
        success: function (data) {
          $("#roleList").html(data)
        },
        async: false
      })
      $(this).addClass("current")
      $(this).siblings().removeClass("current")
    })
  </script>
</body>

</html>